package vg.com.slidingmenu;

import kds.common.UIHelper;
import kds.slm.SlidingMenu;
import kds.slm.app.SlidingFragmentActivity;
import vg.com.chatonline.activity.R;
import android.content.res.Resources;
import android.os.Bundle;

public class BaseApplicationActivity extends SlidingFragmentActivity {
	protected Resources res;
	private SlidingMenu menu;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		res = getResources();
		initSildeMenu();
		getSupportActionBar().setDisplayHomeAsUpEnabled(true);

	}

	@Override
	public boolean onMenuItemSelected(int featureId,
			com.kds.abs.view.MenuItem item) {
		int itemId = item.getItemId();
		switch (itemId) {
		case android.R.id.home:
			if (menu != null) {
				menu.toggle();
			}
			break;
		}
		return true;
	}

	private void initSildeMenu() {
		// set the Behind View
		setBehindContentView(R.layout.frame_layout);
		
		SlidingMenu sm = getSlidingMenu();
		sm.setShadowWidth((int) UIHelper.convertPixel2Dp(
				getApplicationContext(), 25));
		// sm.setShadowDrawable(R.drawable.sld_shadow);
		sm.setMode(SlidingMenu.LEFT);
		sm.setBehindScrollScale(0.0f);
		sm.setBehindOffset(getResources().getDisplayMetrics().widthPixels / 6);
		sm.setFadeDegree(1.0f);
		// sm.setBackgroundColor(res.getColor(R.color.leftmenu_bg));
		sm.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN);
	}

}
